package com.actions;

import javax.servlet.http.*;
import javax.swing.JOptionPane;

import java.util.*;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.beans.*;
import com.DAO.*;
public class AddCategoryAction extends org.apache.struts.action.Action{

	private final static String SUCCESS = "success";
    
    
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
    	
    	
    	
    	
    	CategoryForm categoryForm =(CategoryForm)form;
    	CategoryDAO categoryDao=new CategoryDAO();
    	String value=request.getParameter("allowComment");
    	System.out.println("value of button is......."+value);
    	categoryForm.setAllowComment(value);
    	String Category= categoryForm.getName();
    	
    	System.out.println("category is.........."+Category);
    	
    	
    	//System.out.println("---------------------------------- id is...."+id);
    	
    	
    	
    	int rowsAffected;
    	System.out.println("Enter in action.........................");
    	System.out.println("insert Value"+request.getParameter("insert"));
    	
    	
    	
    	 
     		System.out.println("In Insert  function.........................");
     		rowsAffected=categoryDao.insert(Category,value);
     	
    	
    	
    	return mapping.findForward(SUCCESS);
		
	} 
}